package domd2;

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner input=new Scanner(System.in);
        int n=input.nextInt();
        int sum=0;
        for (int i = 1; i <=n ; i++) {
            if(i%7==0||i%10==7||i/10==7)
            {
                continue;
            }else
            {
                sum=sum+i*i;
            }
        }
        System.out.print(sum);
    }
}
